'''import logging

import requests
from api.inrmEmpManageApi import EmpManageApi

class TestAddEmp(object):

    def setup_class(self):
        self.emp = EmpManageApi()

        resp = requests.post(url="http://ihrm2-test.itheima.net/api/sys/login",
                             json={"mobile": "13800000002", "password": "123456"})
        token = resp.json().get("data")
        self.req_header = {"Content-Type": "application/json",
                           "Authorization": token}

    def test01_add_success(self):
        req_body = {
            "username": "小白007",
            "mobile": "13193916720",
            "workNumber": "9527"
        }
        resp = self.emp.add_emp(self.req_header,req_body)
        # print("添加成功：",resp.json())
        logging.info(f"添加成功：{resp.json()}")

'''

from api.inrmEmpManageApi import EmpManageApi
import requests
from common.dbTools import DBToolos
from common.assertTools import common_assert
from common.readJsonTools import read_json_file
import pytest

from config import mobile, project_pach


class TestAddEmp(object):
    def setup_class(self):
        self.emp = EmpManageApi()
        resp = requests.post(url="http://ihrm2-test.itheima.net/api/sys/login",
                             json={"mobile": "13800000002", "password": "123456"})
        token = resp.json().get("data")
        self.req_header = {"Content-Type": "application/json", "Authorization": token}

    def setup(self):
        DBToolos.db_iud(f"delete from bs_user where mobile = '{mobile}';")

    def teardown(self):
        DBToolos.db_iud(f"delete from bs_user where mobile = '{mobile}';")

    file_name = "D:\pythonCode\ihrmAuto\data\ihrmAddData.json"
    data = read_json_file(file_name)

    @pytest.mark.parametrize("desc, req_body, status_code, success, code, message", data)
    def test_add_emp(self, desc, req_body, status_code, success, code, message):
        resp = self.emp.add_emp(self.req_header, req_body)
        # print(desc, "：", resp.json())
        common_assert(resp, status_code, success, code, message)
